using System;
using System.IO;
using Servlets.Exceptions;
using System.Linq;
using Servlets.Api;

namespace Servlets.Http
{
	public class PlainFileBody : IBody
	{
		public object this [string key] {
			get{
				return RawBody;
			}
		}
		
		/// <summary>
		/// ** NOT IMPLEMENTED **
		/// </summary>
		public IValue<string> Value{get{throw new MethodNotImplementedException("Value");}}
		
		/// <summary>
		/// ** NOT IMPLEMENTED **
		/// </summary>
		public IValue<WebFile> File{get{throw new MethodNotImplementedException("File");}}
		
		public byte[] RawBody{get;private set;}
		
		public void ParseStream(StreamReader reader, string contentType, int contentLength) {
			BinaryReader binaryReader = new BinaryReader(reader.BaseStream);
			byte[] bytes = binaryReader.ReadBytes(contentLength);
			RawBody = bytes;
		}
	}
}

